const spawn = require("cross-spawn");

async function executeNodeScript({cwd}, data, source) {
  return new Promise((resolve => {
    const child = spawn(
      process.execPath, //node可执行文件的路径
      ['-e', source, '--', JSON.stringify(data)],
      {cwd, stdio: 'inherit'}
    );
    child.on('close', resolve);
  }));
}

//node -e "console.log('aaa')"
